package com.kejso.model.solr;

import com.kejso.model.Score;
import org.apache.solr.client.solrj.beans.Field;
import org.springframework.data.annotation.Id;
import org.springframework.data.solr.core.mapping.SolrDocument;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zzq
 * @e-mail 191550636@qq.com
 */
@SolrDocument(solrCoreName = "scholar")
public class SolrScholar implements Serializable {

    @Id
    private String id;//学者ID（唯一）

    //与排名相关的信息
    @Field("name_is")
    private String name;//学者姓名
    @Field("org_if")
    private String org;//学者工作单位
    @Field("depart_ais")
    private String depart;//学者工作部门

    @Field("degree_ims")
    private List<String> degrees;//学者职称，如：讲师、副教授、教授、博导、院士等
    @Field("position_ims")
    private List<String> positions;//学者职务，如：主任、副院长、院长

    @Field("committee_ais")
    private String committees;//学者所处委员会（社会兼职）
    @Field("committee_position_ais")
    private String committeePositions;//学者委员会职务（社会兼职职务）
    @Field("title_if")
    private String title;//学者其它头衔
    @Field("edu_level_ais")
    private String eduLevel;//学者学历

    //基础分数
    @Field("base_score_d")
    private double baseScore;
    @Field("info_score_d")
    private Double infoScore;//信息完整性分数

    @Field("fields_ims")
    private List<String> fields;//学者研究领域文字
    @Field("fields_weight_md")
    private List<Double> fieldsWeights;//学者各个研究领域的权重分值，和研究领域一一对应
    @Field("fields_artificial_md")
    private List<Double> fieldsArtificial;//学者各个研究领域的人工权重分值，每个暂定:词-分数

    //与排名暂不相关的信息
    @Field("relation_ims")
    private List<String> relations;//学者人物关系网

    @Field("sex_if")
    private String sex;//学者性别
    @Field("birthday_if")
    private String birthday;//学者出生日期
    @Field("contact_ais")
    private String contact;//学者联系方式
    @Field("place_if")
    private String place;//学者单位简略地址
    @Field("address_ais")
    private String address;//学者单位详细地址
    @Field("postcode_s")
    private String postcode;//学者单位邮政编码
    @Field("achievement_ais")
    private String achievement;//学者主要成就
    @Field("experience_ais")
    private String experience;//学者履历
    @Field("prize_ais")
    private String prize;//学者获奖情况记录
    @Field("extra_ais")
    private String extra;//学者其它经历内容
    @Field("resource_url_s")
    private String resourceUrl;//学者信息来源

    //和这个人相关的论文id
    @Field("paper_ids")
    private String paperIds;
    @Field("project_ids")
    private String projectIds;//和这个人项目相关的论文id
    @Field("label_if")
    private String label;//和这个人专利的论文id

    @Field("label_d")
    private String patentIds;//和这个人专利的论文id

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    private List<Score> scores = new ArrayList<>();

    public void initScores(){
        if(fields==null || fieldsWeights==null) {
            fields=new ArrayList<>();
            fieldsWeights = new ArrayList<>();
        }
        int len = Math.min(fields.size(),fieldsWeights.size());
        fields = fields.subList(0,len);
        fieldsWeights = fieldsWeights.subList(0,len);
        for(int i=0;i<fields.size() && fields.size() == fieldsWeights.size();i++){
            Score score = new Score();
            score.setField(fields.get(i));
            score.setFieldWeight(fieldsWeights.get(i));
            this.scores.add(score);
        }
    }

    public List<Score> getScores() {
        return scores;
    }

    public void setScores(List<Score> scores) {
        this.scores = scores;
    }

    public String getIndexes() {
        return indexes;
    }

    public void setIndexes(String indexes) {
        this.indexes = indexes;
    }

    public String getResourceUrl() {
        return resourceUrl;
    }

    public void setResourceUrl(String resourceUrl) {
        this.resourceUrl = resourceUrl;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }

    public String getPrize() {
        return prize;
    }

    public void setPrize(String prize) {
        this.prize = prize;
    }

    public String getExperience() {
        return experience;
    }

    public void setExperience(String experience) {
        this.experience = experience;
    }

    public String getAchievement() {
        return achievement;
    }

    public void setAchievement(String achievement) {
        this.achievement = achievement;
    }

    public String getPostcode() {
        return postcode;
    }

    public void setPostcode(String postcode) {
        this.postcode = postcode;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public List<String> getRelations() {
        return relations;
    }

    public void setRelations(List<String> relations) {
        this.relations = relations;
    }

    public List<Double> getFieldsArtificial() {
        return fieldsArtificial;
    }

    public void setFieldsArtificial(List<Double> fieldsArtificial) {
        this.fieldsArtificial = fieldsArtificial;
    }

    public List<Double> getFieldsWeights() {
        return fieldsWeights;
    }

    public void setFieldsWeights(List<Double> fieldsWeights) {
        this.fieldsWeights = fieldsWeights;
    }

    public List<String> getFields() {
        return fields;
    }

    public void setFields(List<String> fields) {
        this.fields = fields;
    }

    public Double getInfoScore() {
        return infoScore;
    }

    public void setInfoScore(Double infoScore) {
        this.infoScore = infoScore;
    }

    public double getBaseScore() {
        return baseScore;
    }

    public void setBaseScore(Double baseScore) {
        this.baseScore = baseScore;
    }

    public String getEduLevel() {
        return eduLevel;
    }

    public void setEduLevel(String eduLevel) {
        this.eduLevel = eduLevel;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getCommitteePositions() {
        return committeePositions;
    }

    public void setCommitteePositions(String committeePositions) {
        this.committeePositions = committeePositions;
    }

    public String getCommittees() {
        return committees;
    }

    public void setCommittees(String committees) {
        this.committees = committees;
    }

    public List<String> getPositions() {
        return positions;
    }

    public void setPositions(List<String> positions) {
        this.positions = positions;
    }

    public List<String> getDegrees() {
        return degrees;
    }

    public void setDegrees(List<String> degrees) {
        this.degrees = degrees;
    }

    public String getDepart() {
        return depart;
    }

    public void setDepart(String depart) {
        this.depart = depart;
    }

    public String getOrg() {
        return org;
    }

    public void setOrg(String org) {
        this.org = org;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Field("indexes_s")
    private String indexes;//学者索引

    @Override
    public String toString() {
        return "SolrScholar{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", org='" + org + '\'' +
                ", depart='" + depart + '\'' +
                ", degrees=" + degrees +
                ", positions=" + positions +
                ", committees='" + committees + '\'' +
                ", committeePositions='" + committeePositions + '\'' +
                ", title='" + title + '\'' +
                ", eduLevel='" + eduLevel + '\'' +
                ", baseScore=" + baseScore +
                ", infoScore=" + infoScore +
                ", fields=" + fields +
                ", fieldsWeights=" + fieldsWeights +
                ", fieldsArtificial=" + fieldsArtificial +
                ", relations=" + relations +
                ", sex='" + sex + '\'' +
                ", birthday='" + birthday + '\'' +
                ", contact='" + contact + '\'' +
                ", place='" + place + '\'' +
                ", address='" + address + '\'' +
                ", postcode='" + postcode + '\'' +
                ", achievement='" + achievement + '\'' +
                ", experience='" + experience + '\'' +
                ", prize='" + prize + '\'' +
                ", extra='" + extra + '\'' +
                ", resourceUrl='" + resourceUrl + '\'' +
                ", paperIds='" + paperIds + '\'' +
                ", projectIds='" + projectIds + '\'' +
                ", patentIds='" + patentIds + '\'' +
                ", indexes='" + indexes + '\'' +
                '}';
    }
}
